Skip to content

Issue #790: Fix entityIdPath#815

Draft
cbeach47 wants to merge 4 commits intomainfrom
bugfix/issue-790/adjust-entity-id-path
Draft

Issue #790: Fix entityIdPath#815
cbeach47 wants to merge 4 commits intomainfrom
bugfix/issue-790/adjust-entity-id-path

Conversation

@cbeach47
Copy link
Contributor

Description of Change

Modifies the transformation API to allow an entityIdPath that are a CSV of entity/attribute IDs.

Related Issues

Related to #790

WIP.

@cbeach47
Copy link
Contributor Author

cbeach47 commented Jan 27, 2026

MDR should be able to map an attribute from each scenario:

  • Base LIF > literal attribute

  • Base LIF > associated attribute from Base LIF

  • Base LIF > associated by reference entity from Base LIF > required attribute in Base LIF from referenced entity

  • Base LIF > associated by embedded entity from Base LIF > attribute (opt/req) in Base LIF from embedded entity

  • Source Schema has the same scenarios as Base LIF.

  • Org LIF > literal attribute

  • Org LIF > associated attribute from Org LIF

  • Org LIF > associated by reference entity from Org LIF > required attribute in Org LIF from referenced entity

  • Org LIF > associated by embedded entity from Org LIF > attribute (opt/req) in Org LIF from embedded entity

  • Org LIF > associated attribute from Base LIF

  • Org LIF > associated by reference entity from Base LIF > required attribute in Base LIF from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Base LIF > attribute (opt/req) in Base LIF from embedded entity

  • Org LIF > associated attribute from Source Schema

  • Org LIF > associated by reference entity from Source Schema > required attribute in Source Schema from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Source Schema > attribute (opt/req) in Source Schema from embedded entity

  • Org LIF > associated attribute from Partner LIF

  • Org LIF > associated by reference entity from Partner LIF > required attribute in Partner LIF from referenced entity (entity must be embedded first)

  • Org LIF > associated by embedded entity from Partner LIF > attribute (opt/req) in Partner LIF from embedded entity

  • Partner LIF has the same scenarios as Org LIF, however, the create/edit schema flows may be different / locked down for Partner LIFs. Using the scenarios for mapping are all valid however.

@cbeach47 cbeach47 force-pushed the bugfix/issue-790/adjust-entity-id-path branch from 4f7c81d to d127ca2 Compare January 28, 2026 13:09
return result.scalar_one_or_none() is not None


async def check_entity_association_strict(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using this instead of check_existing_association? There are cases where ExtendedByDataModelId could be null:

  • If data model type is BaseLIF or SourceSchema, then I think the ExtendedByDataModelId will always be null.
  • If the data model type is OrgLIF or PartnerLIF then the ExtendedByDataModelId may or may not be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like that it was an 'or' condition in check_existing_association. I felt we should be able to determine what value the ExtendedByDataModelId should be prior to invoking the method.

Copy link

@mgwozdz-unicon mgwozdz-unicon Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been having a hard time trying to determine how we could reverse engineer the ExtendedByDataModelId of the association. I think what I said in my other comment is true that for the OrgLIF and PartnerLIF, these are the cases where ExtendedByDataModelId of the association will not be null:

  1. The entity/attribute itself is an Extension and has ExtendedByDataModelId non-null.
  2. Someone used "+ Existing" to create an association in their OrgLIF or PartnerLIF that does not exist in BaseLIF.

That 2nd case is difficult to discern. The only thing I can think of to prove this is:

  1. If the Association has Extension=true, then ExtendedByDataModelId=anchor_data_model_id.

But we're trying to fetch the Association based off of this info, so we don't know yet whether or not it's an extension. I guess if you wanted, you could fetch the Association with the 'or' condition and then check if Extension=true and if it does then check that ExtendedByDataModelId=anchor_data_model_id.

Copy link
Contributor Author

@cbeach47 cbeach47 Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like from your last paragraph we can determine existance by the query:

!Extension AND ExtendedByDM == AnchorDM
OR 
Extension AND ExtendedByDM == Null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's backwards. And to summarize the full context:
If data_model_type == BaseLIF or SourceSchema, then Extension is always False and ExtendedByDataModelId is always null.
If data_model_type == OrgLIF or PartnerLIF, then...

!Extension AND ExtendedByDM == Null
OR 
Extension AND ExtendedByDM == AnchorDM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 I coded it the way you just noted , but then wrote my comment backwards.

in [DataModelType.BaseLIF, DataModelType.SourceSchema],
)

extended_by_data_model_id = None if originates_in_anchor else anchor_data_model.Id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the data model is BaseLIF or SourceSchema, then the association's extended_by_data_model_id should equal null always.
If the data model is OrgLIF or PartnerLIF, then the association's extended_by_data_model_id should be non-null if:

  1. The entity/attribute itself is an Extension and has ExtendedByDataModelId non-null.
  2. Someone used "+ Existing" to create an association in their OrgLIF or PartnerLIF that does not exist in BaseLIF.

I don't think we need to try to calculate which of these situations we're in though. I think it's okay to just always check for the association with extended_by_data_model_id = null or anchor_data_model_id, which is what I'm trying to suggest in my other comment when I say that I think you should use the check_entity_association method instead of the check_entity_association_strict method. Same for checking the entity-attribute association.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was revising this, and realized that using check_entity_association could fail if there is an match with a null extended_by_data_model_id and a extended_by_data_model_id with a value in the database. Might need to call it twice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic we've discussed in the comment thread for check_entity_association_strict will address this. If I'm understanding correctly, I think you can either call it twice or include an OR operator in the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants